package gui;

import java.awt.Color;
import javax.swing.JTextArea;
import modelcontroller.Conversation;

/**
 *
 * @author Mariam
 */
public class ConversationArea extends JTextArea {

    private Conversation conversation;

    /**
     * Constructs a zone where the conversation is displayed
     *
     * @param conversation the conversation to display
     */
    public ConversationArea(Conversation conversation) {
        super(25, 50);
        this.conversation = conversation;
        initComponents();
    }

    private void initComponents() {
        //this.setBackground(new Color(237, 237, 237));
        this.setEditable(false);
        this.setForeground(new Color(128, 0, 128));
    }

    /**
     * Gets the conversation associated to the conversation area
     *
     * @return the conversation
     * @see Conversation
     */
    public Conversation getConversation() {
        return conversation;
    }

    /**
     * Creates a conversation area to welcome the user connected to the Chat
     * System and give him some advice
     *
     * @param username the login of the local user
     * @return the welcome conversation area
     */
    public static ConversationArea welcomeConversationArea(String username) {
        ConversationArea c = new ConversationArea(null);
        c.setText("  Hi " + username + " ! \n Please select a user in the list to start chating :)\n"
                + " To close a tab, click right on it"
                + "\n\n  ChatSystem v1 by Mariam Kadoura (RTA1)");
        return c;
    }
}
